import socket
import sys
#modify
#remodify

def socket_client():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(('127.0.0.1', 1024))
    except socket.error as msg:
        print(msg)
        sys.exit(1)
    print(s.recv(1024).decode())  # 目的在于接受：Accept new connection from (...
    while 1:
        data = input('please input message ready sending: ').encode()
        s.send(data)
        print('recv:', s.recv(1024).decode())
        if data == 'exit':
            break
    s.close()


if __name__ == '__main__':
    #print("master")
    socket_client()
